/**
 * 权限相关的数据
 * Created by gcc on 2017/9/29.
 */
import Vue from "vue";
import  { Tooltip } from 'view-design'

// 页码相关
let page = {
  total: 1,
  startIndex: 0,
  stepNumber: 40,
  currentPage: 1
};
//页面状态相关
let status = {};

// 和网络交互相关的参数
let params = {
  changeStateCustomerInfo: {
    id: "",
    number:""
  }
};

// 页面的数据源
let data = {
  userList: [],
};

let tableTitles = function (self) {
  return [
    // {
    //   type: 'selection',
    //   align: 'center',
    //   fixed: 'left',
    //   width: 60
    // },
    {
      type: 'index',
      title: '#',
      width: 70,
      key: 'index',
      align: 'center',
    },
    // {
    //   title: '用户名',
    //   width: 200,
    //   key: 'name',
    //   align:'center',
    //   render: (h, params) => {
    //     let username = Vue.prototype.$tiyHideUsername(params.row.name);
    //     return (
    //       <div>
    //         <Tooltip content={params.row.name} placement="top">{username}</Tooltip>
    //       </div>
    //     );
    //
    //   }
    // },
    {
      title: '独立站编号',
      width: 180,
      key: 'number',
      align:'center'
    },
    {
      title: '独立站',
      key: 'externalUrl',
      width: 120,
      render: (h, params) => {

        let externalUrl = params.row.externalUrl;
        if (!externalUrl){
          return (
            <div><span></span></div>
          );
        }else{

          return (
            <div>
              <Tooltip content={externalUrl} placement="top">
                <a target='_blank' href={externalUrl}> 点击访问 </a>
              </Tooltip>
            </div>
          );
        }

      }
    },
    {
      title: '邮箱',
      width: 200,
      key: 'externalEmail',
      render: (h, params) => {
        return params.row.externalEmail?h("div",params.row.externalEmail):h("div","暂无");
      }
    },
    {
      title: '负责员工',
      key: 'employeeName',
    },
    {
      title: '操作',
      width: 120,
      fixed: 'right',
      key: 'createtime',
      render: (h, params) => {
        return self.$authority("OPERATIONS-4-201")?h('div', [h('Button', {
          props: {type: 'success', size: 'small', icon: "md-checkmark"},
          style: {
            marginRight: '10px'
          },
          on: {
            click: () => {
              self.setEffective(params.index);
            }
          }
        }, '改为有效')
        ]):h('div',"");
      }
    }
  ];
}
let role = {};

export  default  {
  tStatus: status,
  tParams: params,
  tData: data,
  tPage: page,
  tableTitles: tableTitles
};
